﻿<#
参数说明
Type：站点类型 parent 主站点 children 应用程序
parentName：应用程序所属主站点名称
Name：主站点或应用程序名称
Post：主站点绑定端口号
WebType：主站点或应用程序所属类型  wcf - wcf服务  web - 网站
UnzipPath：主站点解压目录
#>

function GetSellConfig(){
    <#$json='[
            {"Type":"parent","parentName":"null","Name":"TestWCF","Post":"8030","WebType":"wcf","UnzipPath":"root"},
            {"Type":"children","parentName":"TestWCF","Name":"01Market_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"03Design_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"05Sales_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"06Project_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"10Warehouse_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"11Supplier_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"11SupplierHR_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"12Technology_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"20HR_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"20HR_WcfHost_New","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"21Finance_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"23Archives_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"30File_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"31SSO_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"33Message_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"50Infrastr_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWCF","Name":"80Identity_WcfHost","Post":"null","WebType":"wcf","UnzipPath":"null"},

            {"Type":"parent","parentName":"null","Name":"AndroidApi_WcfHost","Post":"8040","WebType":"wcf","UnzipPath":"06Project_AndroidApi_WcfHost"},

            {"Type":"parent","parentName":"null","Name":"TestWeb02","Post":"9020","WebType":"web","UnzipPath":"9000_SSO"},
            {"Type":"children","parentName":"TestWeb02","Name":"01Market_Website","Post":"null","WebType":"web","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWeb02","Name":"03Design_Website","Post":"null","WebType":"web","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWeb02","Name":"05Sales_Website","Post":"null","WebType":"web","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWeb02","Name":"06Project_Website","Post":"null","WebType":"web","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWeb02","Name":"10Warehouse_Website","Post":"null","WebType":"web","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWeb02","Name":"11Supplier_Website","Post":"null","WebType":"web","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWeb02","Name":"16SupplierConfig_Website","Post":"null","WebType":"web","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWeb02","Name":"20HR_Website","Post":"null","WebType":"web","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWeb02","Name":"31SSO_Website","Post":"null","WebType":"web","UnzipPath":"null"},
            {"Type":"children","parentName":"TestWeb02","Name":"33MessageCenter_Website","Post":"null","WebType":"web","UnzipPath":"null"}

           ]';#>
    $json='[{"Type":"parent","parentName":"null","Name":"TestWeb02","Post":"8030","WebType":"wcf","UnzipPath":"root"},
            {"Type":"children","parentName":"TestWeb02","Name":"WinRAR","Post":"null","WebType":"wcf","UnzipPath":"null"}
           ]';#>
    <#$json='[{"Type":"parent","parentName":"null","Name":"AndroidApi_WcfHost","Post":"8040","WebType":"wcf","UnzipPath":"06Project_AndroidApi_WcfHost"}]';#>
    return $json|ConvertFrom-Json

}


#获取应用程序配置信息
function GetChildren(){

    param(
        [parameter(Mandatory=$true)]
        [string]$parentName    #父节点名称
    )
    
    $config=GetSellConfig;
    foreach($obj in $config){ 
        if($obj.parentName -eq $parentName){
            $obj
        }
    }
}

